package com.demo.page.controller;

import com.demo.common.pojo.Products;
import com.demo.page.service.ProductFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/page")
@RefreshScope
public class PageController {

    @Value("${server.port}")
    private String port;

    @Value("${user}")
    private String user;

    @Autowired
    private ProductFeign productFeign;


    @RequestMapping("/getData/{id}")
    public Map findDataById(@PathVariable Integer id) {
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("aaa",productFeign.query(id));
        objectObjectHashMap.put("bbb",port);
        System.out.println(user);
        return objectObjectHashMap;
    }

}
